﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "选课管理 - 学期开课情况");

		taskProp = getProperty("serviceFactory").getBean("taskPropertyAdvice");

		termId = event.getArg("TID");
		depId = event.getArg("DepID");
		
		taskIdCanceled = event.getArg("TSKED");

		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		currentTab = event.getArg("TabID", "labDepartment");
		
		rs_departmentEntity = queryNew("institute_id");
		rs_planTask = rs_sportTask = rs_openTask = rs_commonTask = queryNew('course_name');
		
		targetArgs = structNew();
		
		if ( len(termId) ) {
			
			structInsert(targetArgs, "TID", termId, true);
				
			/* 读取课程的开课学院 */
			sql = "	SELECT
						bi.institute_id,bi.institute_name,COUNT(DISTINCT bc.cid) c_count,COUNT(*) r_count
					FROM
						t_task_arrange b
						INNER JOIN t_course bc ON bc.cid = b.cid
						INNER JOIN t_institute bi ON bi.institute_id = bc.institute_id
					WHERE
						b.term_id = :termId 
						AND
						EXISTS(
							SELECT 1 FROM t_task a WHERE a.tsk_id = b.task_id AND
							SUBSTR(a.task_prop,7,1) = '0'
						)
						OR
						EXISTS(
							SELECT 1 FROM t_common_task a WHERE a.tsk_id = b.task_id AND
							SUBSTR(a.task_prop,7,1) = '0'
						)
					GROUP BY
						bi.institute_id,bi.institute_name
					ORDER BY
						bi.institute_name";
			
			queryObj = new Query(datasource = application.dnsSlave);
			queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
			rs_ins = queryObj.execute(sql = sql).getResult();

			/* 设置默认开课单位 
			if ( rs_ins.recordCount and depId eq "") {
				depId = insArray[1][1];
			}
			*/
			
			
			if ( depId neq "") {
			
				structInsert(targetArgs, "DepID", depId, true);
			
				currentTab = "labTask";
			
				/* 任课单位信息 */
				sql = "	SELECT
							i.institute_id,i.institute_name
						FROM
							t_institute i 
						WHERE
							i.institute_id = :depId ";
				
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "depId", value = depID, cfsqltype = "cf_sql_varchar");
				rs_departmentEntity = queryObj.execute(sql = sql).getResult();
			
				/* 读取选课学期教学任务 */
				sql = "	SELECT
								ac.course_name,a.cidx,
								at.tch_name, ac.prop_id, 
								a.task_limite,a.task_chooesd,a.task_capacity,au.campus_name,
								a.task_week,a.task_period,
								ai.institute_short,
								a.task_prop,a.tsk_id,
								ast.tch_name tch_name_sec,
								aat.tch_name tch_name_ace
							FROM
								t_task a INNER JOIN t_teacher at ON at.tch_id = a.tch_id
								INNER JOIN t_course ac ON ac.cid = a.cid INNER JOIN t_campus au ON au.campus_id = a.campus_id
								INNER JOIN t_institute ai ON ai.institute_id = ac.institute_id INNER JOIN t_teacher ast ON ast.tch_id = a.tch_id_sec
								INNER JOIN t_teacher aat ON aat.tch_id = a.tch_id_ace
							WHERE
								a.term_id = :termId 
								AND
								ai.institute_id = :depId 
							ORDER BY
								SUBSTR(a.task_prop,7,1),ac.course_name,a.cidx";
					
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "depId", value = depId, cfsqltype = "cf_sql_varchar");
				rs_planTask = queryObj.execute(sql = sql).getResult();		
				
				

					/*
														and 
														exists (from TaskArrange b where a.TaskID = b.TaskID and Term.TermID = :termId) 
			
					*/
				sql = "	SELECT
								ac.course_name,a.cidx,
								at.tch_name,
								a.task_limite,a.task_chooesd,a.task_capacity,au.campus_name,
								a.task_week,a.task_period,
								ai.institute_short,
								a.task_prop,a.tsk_id,
								ast.tch_name tch_name_sec,
								aat.tch_name tch_name_ace
							FROM
								t_common_task a INNER JOIN t_teacher at ON at.tch_id = a.tch_id
								INNER JOIN t_course ac ON ac.cid = a.cid INNER JOIN t_campus au ON au.campus_id = a.campus_id
								INNER JOIN t_institute ai ON ai.institute_id = ac.institute_id INNER JOIN t_teacher ast ON ast.tch_id = a.tch_id_sec
								INNER JOIN t_teacher aat ON aat.tch_id = a.tch_id_ace
							WHERE
								a.term_id = :termId 
								AND
								ai.institute_id = :depId 
							ORDER BY
								SUBSTR(a.task_prop,7,1),ac.course_name,a.cidx";

				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "depId", value = depId, cfsqltype = "cf_sql_varchar");
				rs_commonTask = queryObj.execute(sql = sql).getResult();	
					/*
															and 
															exists (from TaskArrange b where a.TaskID = b.TaskID and Term.TermID = :termId) 
					*/
				sql = "	SELECT
								ac.course_name,a.cidx,
								at.tch_name,
								a.task_limite,a.task_chooesd,a.task_capacity,au.campus_name,
								a.task_week,a.task_period,
								ai.institute_short,
								a.task_prop,a.tsk_id,
								ast.tch_name tch_name_sec,
								aat.tch_name tch_name_ace
							FROM
								t_reopen_task a INNER JOIN t_teacher at ON at.tch_id = a.tch_id
								INNER JOIN t_course ac ON ac.cid = a.cid INNER JOIN t_campus au ON au.campus_id = a.campus_id
								INNER JOIN t_institute ai ON ai.institute_id = ac.institute_id INNER JOIN t_teacher ast ON ast.tch_id = a.tch_id_sec
								INNER JOIN t_teacher aat ON aat.tch_id = a.tch_id_ace
							WHERE
								a.term_id = :termId 
								AND
								ai.institute_id = :depId 
							ORDER BY
								SUBSTR(a.task_prop,7,1),ac.course_name,a.cidx";

				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "depId", value = depId, cfsqltype = "cf_sql_varchar");
				rs_openTask = queryObj.execute(sql = sql).getResult();	
				
				sql = "	SELECT
								ac.course_name,a.cidx,
								at.tch_name,
								a.task_limite,a.task_chooesd,a.task_capacity,au.campus_name,
								a.task_week,a.task_period,
								ai.institute_short,
								a.task_prop,a.tsk_id,
								ast.tch_name tch_name_sec,
								aat.tch_name tch_name_ace
							FROM
								t_sport_task a INNER JOIN t_teacher at ON at.tch_id = a.tch_id
								INNER JOIN t_course ac ON ac.cid = a.cid INNER JOIN t_campus au ON au.campus_id = a.campus_id
								INNER JOIN t_institute ai ON ai.institute_id = ac.institute_id INNER JOIN t_teacher ast ON ast.tch_id = a.tch_id_sec
								INNER JOIN t_teacher aat ON aat.tch_id = a.tch_id_ace
							WHERE
								a.term_id = :termId 
								AND
								ai.institute_id = :depId 
							ORDER BY
								SUBSTR(a.task_prop,7,1),ac.course_name,a.cidx";

				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "depId", value = depId, cfsqltype = "cf_sql_varchar");
				rs_sportTask = queryObj.execute(sql = sql).getResult();
		
				if ( rs_commonTask.recordCount and rs_planTask.recordCount eq 0 ) {
					currentTab = "labCommonTask";
				}
				
				if ( rs_openTask.recordCount and rs_commonTask.recordCount eq 0 and rs_planTask.recordCount eq 0 ) {
					currentTab = "labOpenTask";
				}
				
				if ( rs_sportTask.recordCount and rs_commonTask.recordCount eq 0 and rs_planTask.recordCount eq 0 and rs_openTask.recordCount eq 0 ) {
					currentTab = "labSportTask";
				}
			
			}
			
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('setStudentCourse', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">预置课表</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i><cfif len(termId)><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput>学期</cfif>教学任务
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<cfif termId eq "">
					<!-- termSelector -->
					<cfoutput>#event.getArg("termSelector")#</cfoutput>
					<!-- /termSelector -->
				</cfif>
				
				<cfif len(termId)>
					<div class="UItab">
						<div class="tabLables">
							<span <cfif currentTab eq "labDepartment">class="active"</cfif> id="labDepartment" tabTarget="Department">开课部门</span>
							<cfif rs_planTask.recordCount>
								<span <cfif currentTab eq "labTask">class="active"</cfif> id="labTask" tabTarget="Task">计划课程教学任务</span>
							</cfif>
							<cfif rs_commonTask.recordCount>
								<span <cfif currentTab eq "labCommonTask">class="active"</cfif> id="labCommonTask" tabTarget="CommonTask">通选课教学任务</span>
							</cfif>
							<cfif rs_openTask.recordCount>
								<span <cfif currentTab eq "labOpenTask">class="active"</cfif> id="labOpenTask" tabTarget="OpenTask">单开班教学任务</span>
							</cfif>
							<cfif rs_sportTask.recordCount>
								<span <cfif currentTab eq "labSportTask">class="active"</cfif> id="labSportTask" tabTarget="SportTask">体育项目</span>
							</cfif>
						</div>
					</div>
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$(document).ready(function() {
						
							/* init Tab */
							$("div.tabContent").hide();
							$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
					
							$("div.tabLables > span").click(function(){
								var $targetID = $(this).attr("tabTarget");
							
								$("div.tabLables span").removeClass("active");
								$(this).addClass("active");
							
								$("div.tabContent").not('[id="' + $targetID + '"]').hide();
								$("div.tabContent#" + $targetID).show();
							});
					
						});
						// -->
						//]]>
					</script>
				
					<div id="Department" class="tabContent">
					
						<div class="noticeBlock">
							<div class="operation">
								<a class="uiButton" href="<cfoutput>#buildURL('taskChooserflush', targetArgs)#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">重新计算已选人数</span></a>
								<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('taskDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载全校教学任务</span></a>
							</div>
							<h3>开课部门概况</h3>
							<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期教学任务共计 <em><cfoutput>#rs_ins.recordCount#</cfoutput></em> 个任课单位共同完成.</p>
							<hr/>
						</div>
					
						<div class="clearfix">
							<div class="UICardTable">

                                <cfloop query="rs_ins">
									<cfset structInsert(targetArgs, "DepID", rs_ins.institute_id, true) />
									<dl>
										<dt>
											<a href="<cfoutput>#buildURL('taskClass', targetArgs)#</cfoutput>">
											<em class="collection"><!--imgholder--></em>
											<dd>
												<h3><cfoutput>#rs_ins.institute_name#</cfoutput></h3>
												<div>课程:<cfoutput>#rs_ins.c_count#</cfoutput> 教学班:<cfoutput>#rs_ins.r_count#</cfoutput></div>
											</dd>
											</a>
										</dt>
									</dl>
								</cfloop>
							</div>
						</div>
					</div>

					<div id="Task" class="tabContent">
					
						<cfif rs_departmentEntity.recordCount>
							<cfset structInsert(targetArgs, "DepID", rs_departmentEntity.institute_id, true) />
							<div class="noticeBlock">
								<div class="operation">
									<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('depTaskDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载学院教学任务</span></a>
								</div>
								<h3><cfoutput>#rs_departmentEntity.institute_name#</cfoutput></h3>
								<p>
									<span class="img icon16x16 message"></span>
									<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 
									需承担计划课程教学任务 <em><cfoutput>#rs_planTask.recordCount#</cfoutput></em> 个
									.
								</p>
								<hr/>
							</div>
						</cfif>
					
						<cfif rs_planTask.recordCount>
                              
							<table class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td>校区2</td>
										<td>教学班</td>
                                                  <td>类型</td>
										<td>教师</td>
										<td width="35">周次</td>
										<!---<td width="36">周学时</td>--->
										<td align="center" width="60">人数</td>
										<td width="25">上限</td>
										<td width="110">调整任务计划人数</td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
									<cfset row = 0 />

									<cfloop query="rs_planTask">
                                             <cfset writeLog( text=rs_planTask.tsk_id ) />
										<cfset row++ />
									
										<cfset structInsert(targetArgs, "TSK", rs_planTask.tsk_id, true) />
										<cfset structInsert(targetArgs, "TT", "P", true) />
									
										<cfset taskProp.parseProperty( rs_planTask.task_prop ) />
									
										<tr class="editRows <cfif taskIdCanceled eq rs_planTask.tsk_id>alertRow</cfif> <cfif taskProp.getCancel()>cancelRow</cfif>" rowid="<cfoutput>#rs_planTask.tsk_id#</cfoutput>">
											<td class="index">P.<cfoutput>#row#</cfoutput></td>
											<td><cfoutput>#rs_planTask.campus_name#</cfoutput></td>
											<td>
												<cfif taskProp.getCancel()>
													<span class="numeric">[<cfoutput>#rs_planTask.cidx#</cfoutput>]</span><cfoutput>#rs_planTask.course_name#</cfoutput>
												<cfelse>
													<span class="numeric">[<cfoutput>#rs_planTask.cidx#</cfoutput>]</span><a href="<cfoutput>#buildURL('taskClassDetail', targetArgs)#</cfoutput>"><cfoutput>#rs_planTask.course_name#</cfoutput></a>
												</cfif>
											</td>
                                                       <td>
                                                       	<cfif rs_planTask.prop_id eq '1'>
													必修
													<cfelse>
                                                                 <font color="#FF0000">选修</font>
                                                            </cfif>
											</td>
                                                       
											<td>
												<cfoutput>#rs_planTask.tch_name#</cfoutput>
												<cfif rs_planTask.tch_name neq rs_planTask.tch_name_sec> / <cfoutput>#rs_planTask.tch_name_sec#</cfoutput></cfif>
												<cfif rs_planTask.tch_name neq rs_planTask.tch_name_ace> / <cfoutput>#rs_planTask.tch_name_ace#</cfoutput></cfif>
											</td>
											<td><span class="numeric"><cfoutput>#rs_planTask.task_week#</cfoutput></span></td>
											<!---<td align="center"><span class="numeric"><cfoutput>#rs_planTask.task_period#</cfoutput></span></td>--->
											<td align="center"><span class="numeric"><cfoutput>#rs_planTask.task_chooesd#</cfoutput> / </span><span filed="planSize" class="numeric" rowid="<cfoutput>#rs_planTask.tsk_id#</cfoutput>"><cfoutput>#rs_planTask.task_limite#</cfoutput></span></td>
											<td align="center"><cfif rs_planTask.task_capacity><span class="numeric"><cfoutput>#rs_planTask.task_capacity#</cfoutput></span><cfelse>-</cfif></td>
											<cfif taskProp.getCancel()>
													<td>已撤班</td>
													<td><a href="javascript:restore('<cfoutput>#rs_planTask.tsk_id#</cfoutput>','P');" class="stat restore" title="恢复教学任务"></a></td>
												<cfelse>
													<td>
														<a href="javascript:resize('<cfoutput>#rs_planTask.tsk_id#</cfoutput>','P',10)" class="btn increase">+10</a>
														<a href="javascript:resize('<cfoutput>#rs_planTask.tsk_id#</cfoutput>','P',-10)" class="btn decrease">-10</a>
														<cfif rs_planTask.task_capacity>
															<a href="javascript:maxsize('<cfoutput>#rs_planTask.tsk_id#</cfoutput>','P')" class="btn smax">Max</a>
														</cfif>
													</td>
													<td><a href="<cfoutput>#buildURL('taskClassCancel', targetArgs)#</cfoutput>" class="stat remove" title="取消教学任务"></a></td>
											</cfif>
										</tr>
									</cfloop>
								</tbody>
							</table>
						</cfif>
					</div>

					<div id="CommonTask" class="tabContent">
						
						<cfif rs_departmentEntity.recordCount>
							<cfset structInsert(targetArgs, "DepID", rs_departmentEntity.institute_id, true) />
							<div class="noticeBlock">
								<div class="operation">
									<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('depTaskDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载学院教学任务</span></a>
								</div>
								<h3><cfoutput>#rs_departmentEntity.institute_name#</cfoutput></h3>
								<p>
									<span class="img icon16x16 message"></span>
									<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 
									需承担全校通选课教学任务 <em><cfoutput>#rs_commonTask.recordCount#</cfoutput></em> 个
									.
								</p>
								<hr/>
							</div>
						</cfif>
					
						<cfif rs_commonTask.recordCount>
							<table class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td>校区</td>
										<td>教学班</td>
										<td>教师</td>
										<td width="35">周次</td>
										<!---<td width="36">周学时</td>--->
										<td align="center" width="60">人数</td>
										<td width="25">上限</td>
										<td width="110">调整任务计划人数</td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
									<cfset row = 0 />

                                    <cfloop query="rs_commonTask">
										
										<cfset row++ />
									
										<cfset structInsert(targetArgs, "TSK", rs_commonTask.tsk_id, true) />
										<cfset structInsert(targetArgs, "TT", "C", true) />
									
										<cfset taskProp.parseProperty( rs_commonTask.task_prop ) />
									
										<tr class="editRows <cfif taskIdCanceled eq rs_commonTask.tsk_id>alertRow</cfif> <cfif taskProp.getCancel()>cancelRow</cfif>" rowid="<cfoutput>#rs_commonTask.tsk_id#</cfoutput>">
											<td class="index">C.<cfoutput>#row#</cfoutput></td>
											<td><cfoutput>#rs_commonTask.campus_name#</cfoutput></td>
											<td>
												<cfif taskProp.getCancel()>
													<span class="numeric">[<cfoutput>#rs_commonTask.cidx#</cfoutput>]</span><cfoutput>#rs_commonTask.course_name#</cfoutput>
												<cfelse>
													<span class="numeric">[<cfoutput>#rs_commonTask.cidx#</cfoutput>]</span><a href="<cfoutput>#buildURL('taskClassDetail', targetArgs)#</cfoutput>"><cfoutput>#rs_commonTask.course_name#</cfoutput></a>
												</cfif>
											</td>
											<td>
												<cfoutput>#rs_commonTask.tch_name#</cfoutput>
												<cfif rs_commonTask.tch_name neq rs_commonTask.tch_name_sec> / <cfoutput>#rs_commonTask.tch_name_sec#</cfoutput></cfif>
												<cfif rs_commonTask.tch_name neq rs_commonTask.tch_name_ace> / <cfoutput>#rs_commonTask.tch_name_ace#</cfoutput></cfif>
											</td>
											<td><span class="numeric"><cfoutput>#rs_commonTask.task_week#</cfoutput></span></td>
											<!---<td align="center"><span class="numeric"><cfoutput>#rs_commonTask.task_period#</cfoutput></span></td>--->
											<td align="center"><span class="numeric"><cfoutput>#rs_commonTask.task_chooesd#</cfoutput> / </span><span filed="planSize" class="numeric" rowid="<cfoutput>#rs_commonTask.tsk_id#</cfoutput>"><cfoutput>#rs_commonTask.task_limite#</cfoutput></span></td>
											<td align="center"><cfif rs_commonTask.task_capacity><span class="numeric"><cfoutput>#rs_commonTask.task_capacity#</cfoutput></span><cfelse>-</cfif></td>
											<cfif taskProp.getCancel()>
													<td>已撤班</td>
													<td><a href="javascript:restore('<cfoutput>#rs_commonTask.tsk_id#</cfoutput>','C');" class="stat restore" title="恢复教学任务"></a></td>
												<cfelse>
													<td>
														<a href="javascript:resize('<cfoutput>#rs_commonTask.tsk_id#</cfoutput>','C',10)" class="btn increase">+10</a>
														<a href="javascript:resize('<cfoutput>#rs_commonTask.tsk_id#</cfoutput>','C',-10)" class="btn decrease">-10</a>
														<cfif rs_commonTask.task_capacity>
															<a href="javascript:maxsize('<cfoutput>#rs_commonTask.tsk_id#</cfoutput>','C')" class="btn smax">Max</a>
														</cfif>
													</td>
													<td><a href="<cfoutput>#buildURL('taskClassCancel', targetArgs)#</cfoutput>" class="stat remove" title="取消教学任务"></a></td>
											</cfif>
										</tr>
									</cfloop>
								</tbody>
							</table>
						</cfif>
					</div>

					<div id="OpenTask" class="tabContent">
						
						<cfif rs_departmentEntity.recordCount>
							<cfset structInsert(targetArgs, "DepID", rs_departmentEntity.institute_id, true) />
							<div class="noticeBlock">
								<div class="operation">
									<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('depTaskDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载学院教学任务</span></a>
								</div>
								<h3><cfoutput>#rs_departmentEntity.institute_name#</cfoutput></h3>
								<p>
									<span class="img icon16x16 message"></span>
									<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 
									需承担单开班教学任务 <em><cfoutput>#rs_openTask.recordCount#</cfoutput></em> 个
									.
								</p>
								<hr/>
							</div>
						</cfif>
					
						<cfif rs_openTask.recordCount>
							<table class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td>校区</td>
										<td>教学班</td>
										<td>教师</td>
										<td width="35">周次</td>
										<!---<td width="36">周学时</td>--->
										<td align="center" width="60">人数</td>
										<td width="25">上限</td>
										<td width="110">调整任务计划人数</td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
									<cfset row = 0 />
									<cfloop query="rs_openTask">
										<cfset row++ />
									
										<cfset structInsert(targetArgs, "TSK", rs_openTask.tsk_id, true) />
										<cfset structInsert(targetArgs, "TT", "R", true) />
									
										<cfset taskProp.parseProperty( rs_openTask.task_prop ) />
									
										<tr class="editRows <cfif taskIdCanceled eq rs_openTask.tsk_id>alertRow</cfif> <cfif taskProp.getCancel()>cancelRow</cfif>" rowid="<cfoutput>#rs_openTask.tsk_id#</cfoutput>">
											<td class="index">R.<cfoutput>#row#</cfoutput></td>
											<td><cfoutput>#rs_openTask.campus_name#</cfoutput></td>
											<td>
												<cfif taskProp.getCancel()>
													<span class="numeric">[<cfoutput>#rs_openTask.cidx#</cfoutput>]</span><cfoutput>#rs_openTask.course_name#</cfoutput>
												<cfelse>
													<span class="numeric">[<cfoutput>#rs_openTask.cidx#</cfoutput>]</span><a href="<cfoutput>#buildURL('taskClassDetail', targetArgs)#</cfoutput>"><cfoutput>#rs_openTask.course_name#</cfoutput></a>
												</cfif>
											</td>
											<td>
												<cfoutput>#rs_openTask.tch_name#</cfoutput>
												<cfif rs_openTask.tch_name neq rs_openTask.tch_name_sec> / <cfoutput>#rs_openTask.tch_name_sec#</cfoutput></cfif>
												<cfif rs_openTask.tch_name neq rs_openTask.tch_name_ace> / <cfoutput>#rs_openTask.tch_name_ace#</cfoutput></cfif>
											</td>
											<td><span class="numeric"><cfoutput>#rs_openTask.task_week#</cfoutput></span></td>
											<!---<td align="center"><span class="numeric"><cfoutput>#rs_openTask.task_period#</cfoutput></span></td>--->
											<td align="center"><span class="numeric"><cfoutput>#rs_openTask.task_chooesd#</cfoutput> / </span><span filed="planSize" class="numeric" rowid="<cfoutput>#rs_openTask.tsk_id#</cfoutput>"><cfoutput>#rs_openTask.task_limite#</cfoutput></span></td>
											<td align="center"><cfif rs_openTask.task_capacity><span class="numeric"><cfoutput>#rs_openTask.task_capacity#</cfoutput></span><cfelse>-</cfif></td>
											<cfif taskProp.getCancel()>
													<td>已撤班</td>
													<td><a href="javascript:restore('<cfoutput>#rs_openTask.tsk_id#</cfoutput>','R');" class="stat restore" title="恢复教学任务"></a></td>
												<cfelse>
													<td>
														<a href="javascript:resize('<cfoutput>#rs_openTask.tsk_id#</cfoutput>','R',10)" class="btn increase">+10</a>
														<a href="javascript:resize('<cfoutput>#rs_openTask.tsk_id#</cfoutput>','R',-10)" class="btn decrease">-10</a>
														<cfif rs_openTask.task_capacity>
															<a href="javascript:maxsize('<cfoutput>#rs_openTask.tsk_id#</cfoutput>','R')" class="btn smax">Max</a>
														</cfif>
													</td>
													<td><a href="<cfoutput>#buildURL('taskClassCancel', targetArgs)#</cfoutput>" class="stat remove" title="取消教学任务"></a></td>
											</cfif>
										</tr>
									</cfloop>
								</tbody>
							</table>
						</cfif>
					</div>

					<div id="SportTask" class="tabContent">
						
						<cfif rs_departmentEntity.recordCount>
							<cfset structInsert(targetArgs, "DepID", rs_departmentEntity.institute_id, true) />
							<div class="noticeBlock">
								<div class="operation">
									<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('depTaskDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载学院教学任务</span></a>
								</div>
								<h3><cfoutput>#rs_departmentEntity.institute_name#</cfoutput></h3>
								<p>
									<span class="img icon16x16 message"></span>
									<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 
									需承担体育项目 <em><cfoutput>#rs_openTask.recordCount#</cfoutput></em> 个
									.
								</p>
								<hr/>
							</div>
						</cfif>
					
						<cfif rs_sportTask.recordCount>
							<table class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td>校区</td>
										<td>教学班</td>
										<td>教师</td>
										<td width="35">周次</td>
										<!---<td width="36">周学时</td>--->
										<td align="center" width="60">人数</td>
										<td width="25">上限</td>
										<td width="110">调整任务计划人数</td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
									<cfset row = 0 />
									<cfloop query="rs_sportTask">
										<cfset row++ />
									
										<cfset structInsert(targetArgs, "TSK", rs_sportTask.tsk_id, true) />
										<cfset structInsert(targetArgs, "TT", "T", true) />
									
										<cfset taskProp.parseProperty( rs_sportTask.task_prop ) />
									
										<tr class="editRows <cfif taskIdCanceled eq rs_sportTask.tsk_id>alertRow</cfif> <cfif taskProp.getCancel()>cancelRow</cfif>" rowid="<cfoutput>#rs_sportTask.tsk_id#</cfoutput>">
											<td class="index">T.<cfoutput>#row#</cfoutput></td>
											<td><cfoutput>#rs_sportTask.campus_name#</cfoutput></td>
											<td>
												<cfif taskProp.getCancel()>
													<span class="numeric">[<cfoutput>#rs_sportTask.cidx#</cfoutput>]</span><cfoutput>#rs_sportTask.course_name#</cfoutput>
												<cfelse>
													<span class="numeric">[<cfoutput>#rs_sportTask.cidx#</cfoutput>]</span><a href="<cfoutput>#buildURL('taskClassDetail', targetArgs)#</cfoutput>"><cfoutput>#rs_sportTask.course_name#</cfoutput></a>
												</cfif>
											</td>
											<td>
												<cfoutput>#rs_sportTask.tch_name#</cfoutput>
												<cfif rs_sportTask.tch_name neq rs_sportTask.tch_name_sec> / <cfoutput>#rs_sportTask.tch_name_sec#</cfoutput></cfif>
												<cfif rs_sportTask.tch_name neq rs_sportTask.tch_name_ace> / <cfoutput>#rs_sportTask.tch_name_ace#</cfoutput></cfif>
											</td>
											<td><span class="numeric"><cfoutput>#rs_sportTask.task_week#</cfoutput></span></td>
											<!---<td align="center"><span class="numeric"><cfoutput>#rs_sportTask.task_period#</cfoutput></span></td>--->
											<td align="center"><span class="numeric"><cfoutput>#rs_sportTask.task_chooesd#</cfoutput> / </span><span filed="planSize" class="numeric" rowid="<cfoutput>#rs_sportTask.tsk_id#</cfoutput>"><cfoutput>#rs_sportTask.task_limite#</cfoutput></span></td>
											<td align="center"><cfif rs_sportTask.task_capacity><span class="numeric"><cfoutput>#rs_sportTask.task_capacity#</cfoutput></span><cfelse>-</cfif></td>
											<cfif taskProp.getCancel()>
													<td>已撤班</td>
													<td><a href="javascript:restore('<cfoutput>#rs_sportTask.tsk_id#</cfoutput>','T');" class="stat restore" title="恢复教学任务"></a></td>
												<cfelse>
													<td>
														<a href="javascript:resize('<cfoutput>#rs_sportTask.tsk_id#</cfoutput>','T',10)" class="btn increase">+10</a>
														<a href="javascript:resize('<cfoutput>#rs_sportTask.tsk_id#</cfoutput>','T',-10)" class="btn decrease">-10</a>
														<cfif rs_sportTask.task_capacity>
															<a href="javascript:maxsize('<cfoutput>#rs_sportTask.tsk_id#</cfoutput>','T')" class="btn smax">Max</a>
														</cfif>
													</td>
													<td><a href="<cfoutput>#buildURL('taskClassCancel', targetArgs)#</cfoutput>" class="stat remove" title="取消教学任务"></a></td>
											</cfif>
										</tr>
									</cfloop>
								</tbody>
							</table>
						</cfif>
					</div>

					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						function restore(taskId, taskType) {
								
							$.post(
									"<cfoutput>#buildURL('apiTaskRestore')#</cfoutput>",
									{
									'TSK' : taskId,
									'TT' : taskType,
									'seed': (new Date()).getTime()
									},
									function(data) {
									//$("#out").html(data);
										result = $.parseJSON(data);
												
										if ( result.success ) {
											/* 刷新教学班数据 */
											window.location.reload();
										}
										
									});
						}
							
						function resize(taskId, taskType, step) {
								
							var $tr = $("tr[rowid='" + taskId + "']", $(".UIEditable"));
							var $span = $("span[filed='planSize']", $tr);
								
							$.post(
									"<cfoutput>#buildURL('apiTaskPlanSizeChange')#</cfoutput>",
									{
									'TSK' : taskId,
									'TT' : taskType,
									'STP' : step,
									'seed': (new Date()).getTime()
									},
									function(data) {
										//$("#out").html(data);
										result = $.parseJSON(data);
										
										if ( result.success ) {
											$span.text( result.planSize ).addClass("changed");
										}
										
									});
						}
					
						function maxsize(taskId, taskType) {
									
							var $tr = $("tr[rowid='" + taskId + "']", $(".UIEditable"));
							var $span = $("span[filed='planSize']", $tr);
								
							$.post(
									"<cfoutput>#buildURL('apiTaskPlanSizeChange')#</cfoutput>",
									{
									'TSK' : taskId,
									'TT' : taskType,
									'STP' : 'maxsize',
									'seed': (new Date()).getTime()
									},
									function(data) {
											
										result = $.parseJSON(data);

										if ( result.success ) {
											$span.text( result.planSize ).addClass("changed");
										}
											
									});
										
						}
						// -->
						//]]>
					</script>
				
				</cfif>
				
			</div>
		</li>
	</ul>
</div>


